package org.ihelpuoo.orm.handler.http;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletRequest;

import org.ihelpuoo.lang.StringUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.filter.Filter;
import org.ihelpuoo.orm.handler.ObjectProcessor;

public class HttpSequenceFieldUtils
{
	static List evalObjectList(ObjectProcessor processor, ObjectRule r, Field f, Object src,
			Filter filter, Object parent, Class subType) throws Exception
	{
		String[] ss = StringUtils.splitIgnoreBlank(((ServletRequest)src)
				.getParameter(r.getAlias(f)));
		if (null == ss)
			return null;
		List<Object> list = new ArrayList<Object>(ss.length);
		for (int i = 0; i < ss.length; i++)
			list.add(subType.getConstructor(String.class).newInstance(ss[i]));

		return list;
	}

}
